﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace LanDBom.Models.Procure
{
    public class Find_INF_with_BOMid
    {
        LDbaseEntities LD = new LDbaseEntities();
        //public List<Informa> Find_INF(string LH)
        //{
        //    List<Informa> informas = LD.Informa.Where(x => x.Inf_liao == LH && x.Inf_zhuang=="已提交").ToList();
        //    return informas;
        //}
        public List<Informa> Find_INF(string App_bian,string LH)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_liao == LH && x.Inf_zhuang == "已提交"&&x.Inf_shen==App_bian).ToList();
            return informas;
        }
        public List<Informa> Find_INF()
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == "物料询价").ToList();
            return informas;
        }

        public List<Informa> Find_INF(string App_bian)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == App_bian).ToList();
            return informas;
        }
        public List<Informa> Find_INF(string App_bian, int LHHJ_CP_cktj)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == App_bian).ToList();
            if (LHHJ_CP_cktj == 1)
            {
                informas= informas.GroupBy(d => new { d.Inf_wu }).Select(a=>a.OrderBy(b=>b.Inf_huiP).ElementAt(0)).ToList();
            }
            if (LHHJ_CP_cktj == 3)
            {
                informas = informas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderByDescending(b => b.Inf_huiP).ElementAt(0)).ToList();
            }
            return informas;
        }
        public List<Informa> Find_INF_sx(string App_bian)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == App_bian).ToList();
            List<Informa> informas2 = informas.OrderBy(b => b.Inf_huiP).ToList();
            return informas2;
        }

        public List<Informa> Find_INF_jx(string App_bian)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == App_bian).ToList();
            List<Informa> informas2 = informas.OrderByDescending(b => b.Inf_huiP).ToList();
            return informas2;
        }


        public List<Informa> Find_INF(int LHHJ_CP_cktj)
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == "物料询价").ToList();
            if (LHHJ_CP_cktj == 1)
            {
                informas = informas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderBy(b => b.Inf_huiP).ElementAt(0)).ToList();
            }
            if (LHHJ_CP_cktj == 3)
            {
                informas = informas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderByDescending(b => b.Inf_huiP).ElementAt(0)).ToList();
            }
            return informas;
        }
        public List<Informa> Find_INF_sx()
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == "物料询价").ToList();
            List<Informa> informas2 = informas.OrderBy(b => b.Inf_huiP).ToList();
            return informas2;
        }

        public List<Informa> Find_INF_jx()
        {
            List<Informa> informas = LD.Informa.Where(x => x.Inf_zhuang == "已提交" && x.Inf_shen == "物料询价").ToList();
            List<Informa> informas2 = informas.OrderByDescending(b => b.Inf_huiP).ToList();
            return informas2;
        }
    }
}